#ifndef BLOB_TRACKER_H
#define BLOB_TRACKER_H

#include "opencv2/opencv.hpp"
#include <map>

struct TargetBlob
{
  std::vector<cv::Point> currentContour;
  cv::Rect currentBoundingRect;
  double currentDiagonalLength;
  double currentAspectRatio;

  bool currentMatchFoundOrNewBlob;
  bool stillBeingTracked;
  int intNumOfConsecutiveFramesWithoutAMatch;

  cv::Point predictedNextPosition;
  std::vector<cv::Point> centerPositions;

  std::vector<cv::Mat> rois;
  std::vector<cv::Mat> postrois;
  int camid = -1;
};

class BlobTracker {
public:
  BlobTracker();
  ~BlobTracker();
  void matchCurrentFrameBlobsToExistingBlobs(std::vector<TargetBlob> &existingBlobs, std::vector<TargetBlob> &currentFrameBlobs);
private:
  void predictNextPosition(TargetBlob &existingBlob);
  void addBlobToExistingBlobs(TargetBlob &currentFrameBlob, std::vector<TargetBlob> &existingBlobs, int &intIndex);
  void addNewBlob(TargetBlob &currentFrameBlob, std::vector<TargetBlob> &existingBlobs);
  double distanceBetweenPoints(cv::Point point1, cv::Point point2);
};

#endif  //BLOB_TRACKER_H
